// 入口文件

import Vue from 'vue';
import VueRouter from 'vue-router';
import VueResouse from 'vue-resource';

import App from './App';
import goods from 'components/goods/goods';
import rating from 'components/rating/rating';
import seller from 'components/seller/seller';

import 'common/sass/index.scss';

Vue.use(VueRouter);
Vue.use(VueResouse);

const router = new VueRouter({
  linkActiveClass: 'active',
  // mode: 'history',
  routes: [
    {path: '/rating', component: rating},
    {path: '/goods', component: goods},
    {path: '/goods/:id', component: goods},
    {path: '/seller', component: seller}
  ]
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router: router,
  created() {
    this.$on('pushstate', function (hash) {
      router.push({params: { id: hash }})
    });
  },
  render: h => h(App)
});

if (!location.hash.substr(2)) {
  router.replace('/goods');
}

// var attachFastClick = require('fastclick');
// attachFastClick(document.body);

// 修改为手动加载
// if ('addEventListener' in document) {
//   document.addEventListener('DOMContentLoaded', function() {
//     FastClick.attach(document.body);
//   }, false);
// }
